package com.qf.czh.vhr.Service;

import com.qf.czh.vhr.Mapper.DepartmentMapper;
import com.qf.czh.vhr.entity.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentService {
    @Autowired
    DepartmentMapper departmentMapper;

    public List<Department> getAllDeps() {
        return departmentMapper.getDepartmentByPid(-1);
    }

    public void addDepartment(Department department) {
        //添加进去的部门肯定要启用的.不然就没意义
        department.setEnabled(true);
        departmentMapper.addDepartment(department);
    }

    public List<Department> getAllDepsWithoutChildren() {
        List<Department> list = departmentMapper.getAllDepsWithoutChildren();
        return list;
    }

    public void deleteDepartmentById(Department department) {
        departmentMapper.deleteDepartmentById(department);
    }
}
